package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.common.RedisConst;
import com.itheima.health.entity.Result;
import com.itheima.health.message.SmsTask;
import com.itheima.health.service.SendCodeService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.SecureRandom;
import java.util.concurrent.TimeUnit;

@RequestMapping("mobile/validateCode")
@RestController
@Slf4j
public class ValidateCodeController {
    @DubboReference
    private SendCodeService sendCodeService;
    @Autowired
    private RedisTemplate redisTemplate;


    @PostMapping("send")
    public Result send(String type, String telephone) {
        sendCodeService.send(type, telephone);
        return new Result(true, MessageConst.SEND_VALIDATECODE_SUCCESS);
    }

}
